#ifndef _HIGHSCORESTATE_H_
#define _HIGHSCORESTATE_H_

#include "GameState.h"
#include "GameFont.h"
#include "Image.h"
#include <string>
#include <vector>


class CHighScoreState : public CGameState
{
public:
	~CHighScoreState();


	void SetNewHighScore(ULONG ulNewHighScore)  
	{ m_ulNewHighScore = ulNewHighScore; }

	
	void OnKeyDown(WPARAM wKey);
	void OnChar(WPARAM wChar);
	void Draw();
	void EnterState();

	static CHighScoreState* GetInstance(CStateManager* pManager);

protected:
	CHighScoreState(CStateManager* pManager);

private:

	void SaveScores();

	
	void AddNewScore(const std::string& strName, ULONG ulScore);

	struct HighScoreData
	{
		std::string strPlayer;
		ULONG ulScore;

		bool operator< (const HighScoreData& other)
		{
			if  (this->ulScore > other.ulScore) 
				return true;
			return false;
		}
	};

	ULONG m_ulNewHighScore;

	bool m_bEnterName;
	
	char m_pCurrentName[26];

	int m_iNameIndex;

	CGameFont* m_pFont;

	typedef std::vector<HighScoreData> THighScoreTable;

	THighScoreTable m_vecHighScores;

	TImagePtr m_pBackgroundImg; 
	TImagePtr m_pTitleImg; 
	
	TImagePtr m_pEntriesBckgndImg;

	TImagePtr m_pEnterNameImg; 
	TImagePtr m_pEnterNameBackImg; 
};

#endif  